package com.manage.platform.controller;

import com.manage.platform.dto.IndicatorSystemTaskDto;
import com.manage.platform.dto.query.IndicatorSystemTaskQuery;
import com.manage.platform.service.impl.IndicatorSystemImpl;
import com.manage.platform.service.impl.OrganizeServiceImpl;
import com.manage.platform.utils.R;
import com.manage.platform.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * YWD
 * 2025/9/22
 */
@AllArgsConstructor
@RestController
@RequestMapping("/indicatorSystem")
@Tag(name = "建设任务-指标体系")
public class IndicatorSystemController {

    private final IndicatorSystemImpl indicatorSystemImpl;
    private final OrganizeServiceImpl organizeServiceImpl;

    @GetMapping("/getIndicatorSystemOneList")
    @Operation(summary = "1.查询指标列表(一级列表)")
    public R<List<CommonVo>> getIndicatorSystemOneList() {
        return R.ok(indicatorSystemImpl.getIndicatorSystemOneList());
    }


    @GetMapping("/getIndicatorSystemTree")
    @Operation(summary = "2.查询指标列表(树形)")
    public R<List<IndicatorSystemTreeVo>> getIndicatorSystemTree(@Schema(description = "一级指标ID")
                                                                 @RequestParam(value = "id", required = false) Long id,
                                                                 @Schema(description = "指标名称")
                                                                 @RequestParam(value = "name", required = false) String name) {
        return R.ok(indicatorSystemImpl.getIndicatorSystemTree(id, name));
    }

    @GetMapping("/getIndicatorSystemTreeOne")
    @Operation(summary = "3.查询指标(树形)(目录)")
    public R<List<IndicatorSystemTreeOneVo>> getIndicatorSystemTreeOne(@Schema(description = "指标ID")
                                                                       @RequestParam(value = "id", required = false) Long id) {
        return R.ok(indicatorSystemImpl.getIndicatorSystemTreeOne(id));
    }

    @GetMapping("/getIndicatorSystemDetails")
    @Operation(summary = "3.查询指标详情")
    public R<IndicatorSystemVo> getIndicatorSystemDetails(@Schema(description = "指标ID")
                                                          @RequestParam(value = "id", required = false) Long id) {
        return R.ok(indicatorSystemImpl.getIndicatorSystemDetails(id));
    }

//    @PostMapping("/saveIndicatorSystemPart")
//    @Operation(summary = "4.添加指标(目录)")
//    public R<Boolean> saveIndicatorSystemPart(@RequestBody IndicatorSystemPartDto dto) {
//        return R.ok(indicatorSystemImpl.saveIndicatorSystemPart(dto));
//    }
//
//    @PostMapping("/updateIndicatorSystemPart")
//    @Operation(summary = "5.修改指标(目录)")
//    public R<Boolean> updateIndicatorSystemPart(@RequestBody IndicatorSystemPartDto dto) {
//        return R.ok(indicatorSystemImpl.updateIndicatorSystemPart(dto));
//    }
//
//    @DeleteMapping("/deleteIndicatorSystem")
//    @Operation(summary = "6.删除指标(目录)")
//    public R<Boolean> deleteIndicatorSystem(@RequestParam(value = "指标体系ID", required = false) Long id) {
//        return R.ok(indicatorSystemImpl.deleteIndicatorSystem(id));
//    }

    //任务列表
    @PostMapping("/getTaskList")
    @Operation(summary = "7.任务列表(树形)")
    public R<List<IndicatorSystemTaskVo>> getTaskList(@RequestBody IndicatorSystemTaskQuery query) {
        return R.ok(indicatorSystemImpl.getTaskList(query));
    }

    @PostMapping("/linkTask")
    @Operation(summary = "8.指标关联任务")
    public R<Boolean> linkTask(@RequestBody IndicatorSystemTaskDto dto) {
        return R.ok(indicatorSystemImpl.linkTask(dto));
    }

    //筛选项=======================================================================================================
    //============================================================================================================
    @GetMapping("/getIndicatorList")
    @Operation(summary = "指标列表(筛选项)")
    public R<List<CommonVo>> getIndicatorList(@Schema(description = "指标名称")
                                              @RequestParam(value = "name", required = false) String name) {
        return R.ok(indicatorSystemImpl.getIndicatorList(name));
    }

    @GetMapping("/getCollegeListPart")
    @Operation(summary = "学院列表(筛选项)")
    public R<List<CommonVo>> getCollegeListPart() {
        return R.ok(organizeServiceImpl.getCollegeListPart());
    }

}
